package cl.utalca.robot.logic;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

import javax.servlet.http.HttpServletRequest;

import cl.utalca.robot.dto.TestCaseDTO;

public class TestCaseLogic {


	public List<TestCaseDTO> createTestCaseList(HttpServletRequest request){

		List<TestCaseDTO> resp = null;


		File file = new File(request.getSession().getServletContext().getRealPath(File.separator) + "/pruebas/prueba");
		Scanner scanner = null;
		try 
		{
			scanner = new Scanner(file);
			resp = new ArrayList<>();
		} 		
		catch (FileNotFoundException e) 
		{
			e.printStackTrace();
			return null;
		}

		while (scanner.hasNextLine())
		{
			String entrada = scanner.nextLine();
			if(entrada.trim().equals("")){
				
				continue;
			}
			else{
			
				String salida = scanner.nextLine();
				
				TestCaseDTO testCase = new TestCaseDTO(entrada, salida);
				resp.add(testCase);
			}
		}		
		scanner.close();
		
		return resp;
	}

	
}
